var num = 0;//记录输入参数的个数

var j, dt, dy;
wn = new array(0.1, 0.2, 0.3, 0.4, 0.5);//保存固有频率数组
kth = new array(0.1, 0.2, 0.3, 0.4, 0.5);//保存阻尼系数数组
//

//
dtx = 320 / 12;
dty = 120;
//
var temptmax = ta;
var temptmin = ta;

ox = dota._x;
oy = dota._y;

function initialize() {
	kthi = 1;
	wni = 1;
	_root.createEmptyMovieClip("mymc", 2);//建立绘图对象
	inputBTN1 = true;
	setProperty("mywn", _visible, "0");
	setProperty("mykth", _visible, "0");
	num = 0;
	wn1 = ""; kth1 = "";
	wn2 = ""; kth2 = "";
	wn3 = ""; kth3 = "";
	wn4 = ""; kth4 = "";
	wn5 = ""; kth5 = "";
}

/*function getmax_xy(){
	temptmax=tao[0];
	temptmin=tao[0];
	for (jr=1;jr<num;jr=jr+1)
	   {  if (temptmax<tao[jr]){temptmax=tao[jr]};
		  if (temptmin>tao[jr]){temptmin=tao[jr]};
	   }
	dt=80/temptmax;
	dy=240*temptmin;
}*/

var xx1, xx2, yy1, yy2, t;
function drawLine(i) {
	//i=9;
	clr = new array(0xffff00, 0xff00, 0xffff, 0xff00ff, 0xff0000);
	var wnt = 0;
	with (_root.mymc) {
		linestyle(2, clr[i], 100);
		if (kth[i] > 0 and kth[i] < 1) {
			kt = math.sqrt(1 - kth[i] * kth[i]);
			y = 1 - math.exp(-kth[i] * wnt) * (math.cos(kt * wnt) + kth[i] / kt * math.sin(kt * wnt));
		}
		if (kth[i] == 0) {
			y = 1 - math.cos(wnt);
		}
		if (kth[i] == 1) {
			y = 1 - (1 + wnt) * math.exp(-wnt);
		}
		if (kth[i] > 1) {
			kt = Math.sqrt(kth[i] * kth[i] - 1);
			s1 = -(kth[i] + kt);
			s2 = -(kth[i] - kt);
			y = 1 + 0.5 * wn[i] / kt * (math.exp(s1 * wnt) / (-s1 * wn[i]) - math.exp(s2 * wnt) / (-s2 * wn[i]));
		}
		moveTo(ox + dtx * wnt, oy - dty * y);
		while (wnt <= 14) {
			wnt = wnt + 12 * 0.025 / 8;
			if (kth[i] > 0 and kth[i] < 1) {
				kt = math.sqrt(1 - kth[i] * kth[i]);
				y = 1 - math.exp(-kth[i] * wnt) * (math.cos(kt * wnt) + kth[i] / kt * math.sin(kt * wnt));
			}
			if (kth[i] == 0) {
				y = 1 - math.cos(wnt);
			}
			if (kth[i] == 1) {
				y = 1 - (1 + wnt) * math.exp(-wnt);
			}
			if (kth[i] > 1) {
				kt = Math.sqrt(kth[i] * kth[i] - 1);
				s1 = -(kth[i] + kt);
				s2 = -(kth[i] - kt);
				y = 1 + 0.5 * wn[i] / kt * (math.exp(s1 * wnt) / (-s1 * wn[i]) - math.exp(s2 * wnt) / (-s2 * wn[i]));
			}
			lineTo(ox + dtx * wnt, oy - dty * y);
		}
		moveTo(575, 190 + i * 30);
		lineTo(590, 190 + i * 30);
	}
};

//

//

initialize();


BTNInput1.onRelease = function () {

	//inputEnd = drawInputFunction(inputEndCondition);
	//drawInputLine(num,100,100,300,300);
	if ((inputBTN1 == true) && (num < 5)) {
		if ((wni != "") && (kthi != "")) {
			if ((wni != 0)) {
				setProperty("mywn", _visible, "1");
				setProperty("mykth", _visible, "1");
				wn[num] = wni; kth[num] = kthi;
				switch (num) {
					case 0: wn1 = wn[num]; kth1 = kth[num]; break;
					case 1: wn2 = wn[num]; kth2 = kth[num]; break;
					case 2: wn3 = wn[num]; kth3 = kth[num]; break;
					case 3: wn4 = wn[num]; kth4 = kth[num]; break;
					case 4: wn5 = wn[num]; kth5 = kth[num]; break;
					default: trace("no case tested true")
				}
				num = num + 1;
				err1 = ""

			}
			else { err1 = "Error" }
		}
		else { err1 = "Error" }
	}
	else { err1 = "请按“清除”按钮" }

}

BTNInput2.onRelease = function () {
	/*	temptmax=tao[0];
		temptmin=tao[0];
		for (j=1;j<num;j=j+1)
		   {  if (temptmax<tao[j]){temptmax=tao[j]};
			  if (temptmin>tao[j]){temptmin=tao[j]};
		   }*/
	if (num == 0) { err1 = "Error" } else {
		//getmax_xy();   
		/*t1 = temptmax;
		t2 = 2*temptmax;
		t3 = 3*temptmax;
		t4 = 4*temptmax;
		x4 = 1/temptmin;
		x3 = 0.75/temptmin;
		x2 = 0.5/temptmin;
		x1 = 0.25/temptmin;*/
		for (jk = 0; jk < num; jk = jk + 1) {
			drawLine(jk);
		}
		inputBTN1 = false;
	}
}

BTNInput3.onRelease = function () {

	initialize();
	inputBTN1 = true;
	err1 = ""
}
